package com.hig.ledger.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hig.ledger.domain.LedgerElectricianCertificate;
import com.hig.ledger.service.ILedgerElectricianCertificateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.servlet.http.HttpServletResponse;

/**
 * 电工证统计Controller
 * 
 * @author scp
 * @date 2024-09-22
 */
@RestController
@RequestMapping("/ledger/electrician")
public class LedgerElectricianCertificateController extends BaseController
{
    @Autowired
    private ILedgerElectricianCertificateService ledgerElectricianCertificateService;

    /**
     * 查询电工证统计列表
     */
    @PreAuthorize("@ss.hasPermi('ledger:electrician:list')")
    @GetMapping("/list")
    public TableDataInfo list(LedgerElectricianCertificate ledgerElectricianCertificate)
    {
        startPage();
        List<LedgerElectricianCertificate> list = ledgerElectricianCertificateService.selectLedgerElectricianCertificateList(ledgerElectricianCertificate);
        return getDataTable(list);
    }

    /**
     * 导出电工证统计列表
     */
    @PreAuthorize("@ss.hasPermi('ledger:electrician:export')")
    @Log(title = "电工证统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(LedgerElectricianCertificate ledgerElectricianCertificate, HttpServletResponse response)
    {
        List<LedgerElectricianCertificate> list = ledgerElectricianCertificateService.selectLedgerElectricianCertificateList(ledgerElectricianCertificate);
        ExcelUtil<LedgerElectricianCertificate> util = new ExcelUtil<LedgerElectricianCertificate>(LedgerElectricianCertificate.class);
        util.exportExcel(response, list, "电工证统计数据");
    }

    /**
     * 获取电工证统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('ledger:electrician:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ledgerElectricianCertificateService.selectLedgerElectricianCertificateById(id));
    }

    /**
     * 新增电工证统计
     */
    @PreAuthorize("@ss.hasPermi('ledger:electrician:add')")
    @Log(title = "电工证统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LedgerElectricianCertificate ledgerElectricianCertificate)
    {
        return toAjax(ledgerElectricianCertificateService.insertLedgerElectricianCertificate(ledgerElectricianCertificate));
    }

    /**
     * 修改电工证统计
     */
    @PreAuthorize("@ss.hasPermi('ledger:electrician:edit')")
    @Log(title = "电工证统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LedgerElectricianCertificate ledgerElectricianCertificate)
    {
        return toAjax(ledgerElectricianCertificateService.updateLedgerElectricianCertificate(ledgerElectricianCertificate));
    }

    /**
     * 删除电工证统计
     */
    @PreAuthorize("@ss.hasPermi('ledger:electrician:remove')")
    @Log(title = "电工证统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ledgerElectricianCertificateService.deleteLedgerElectricianCertificateByIds(ids));
    }
}
